package dao.impl;

import dao.AnimeDao;
import dao.BaseDao;
import pojo.Anime;

import java.util.List;

public class AnimeDaoImplement extends BaseDao implements AnimeDao{
    @Override
    public List<Anime> queryAnimebyName(String name) {
        String sql=" select * from filtrate_by_name(?)";
        return queryForList(Anime.class,sql,name);
    }

    @Override
    public  List<Anime> queryAnimebyType(String type){
        String sql="select * from filtrate_by_type(?)";
        return queryForList(Anime.class,sql,type);
    }
    @Override
    public  List<Anime> queryAnimebyGenre(String genre){
        String sql="select * from filtrate_by_genre(?)";
        return queryForList(Anime.class,sql,genre);
    }


    @Override
    public int saveAnime(Anime anime) {
        String sql="insert into rat_anime values(?,?,?,?,?,?,?)";

        return update(sql,anime.getAnime_ID(),anime.getName(),anime.getGenre(),anime.getType(),anime.getEpisodes(),anime.getRating(),anime.getMembers());
    }

    @Override
    public Anime queryAnimebyId(String anime_ID){
        String sql="select * from rat_anime where anime_id=?";
        return queryForOne(Anime.class,sql,anime_ID);
    }

}
